import heapq


def findKthLargest(nums, k):
    heap = [num * -1 for num in nums]
    heapq.heapify(heap)
    i, temp = 0, 0
    while i < k:
        temp = heapq.heappop(heap)
        i += 1
    return -1 * temp


nums = [6, 1, 2, 3, 5, 4]
print(findKthLargest(nums, 2))  # 5
